/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sip;
import javax.swing.JLabel;
import javax.swing.Timer;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.Date;
/**
 *
 * @author arianareyessantiago
 */
public class BatteryLabel extends JLabel implements ActionListener {
    //public static double batteryLife = 100;

    
    public BatteryLabel(){
        super("" + new Date());
        Timer t = new Timer(1000, this);
        t.start();
    } 
      public void actionPerformed(ActionEvent ae) {
          int decreaseAmount;
        decreaseAmount = (int)(InitSip.batteryLife*.01);
        InitSip.secondsUsed = InitSip.secondsUsed + 1;
        setText(Double.toString(InitSip.BatteryLevel)+"%");
        //SipLogger.Instance().debug(Double.toString(InitSip.secondsUsed));
        if(InitSip.secondsUsed == 60){
        InitSip.BatteryLevel = InitSip.BatteryLevel - 1;
        //System.out.println(batteryLife);
        //setText(Double.toString(InitSip.BatteryLevel)+"%");
        }
        /*Alarm alarm = new Alarm();
        if(batteryLife >= 10 && batteryLife <= 15 ){
            alarm.setAlarm("You currently have 15% or less of your Battery Left!. Change your Batteries.");
            }
        if(batteryLife >= 4 && batteryLife <=9){
            alarm.setAlarm("You currently have 10% or less of your Battery Left!. You are now using Battery Reserve."); 
            }
        if(batteryLife <= 3){
               alarm.play();
        }
        if(batteryLife <= 0){
            System.exit(1);
            }
            */
                  
    }
}

